﻿@using HCMS.Enum
@{
    Layout = "";
}
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"]</title>
    <link rel="stylesheet" href="~/pear/component/layui/css/layui.css" />
    <link rel="stylesheet" href="~/pear/component/pear/css/pear.css" />
    <link rel="stylesheet" href="~/pear/admin/css/admin.css" />
    <link rel="stylesheet" href="~/pear/admin/css/admin.dark.css" />
    <link rel="stylesheet" href="~/pear/admin/css/variables.css" />
    <link rel="stylesheet" href="~/pear/admin/css/reset.css" />
    @await RenderSectionAsync("Styles", required: false)
    <script src="~/js/frontend.monitoring.js"></script>
    <script>
        new FrontendMonitoring({ appId: '@((int)FrontEndMonitoringAppType.Manage)', uploadUrl: '/home/frontendmonitoring/' });
    </script>
    <script src="~/pear/component/layui/layui.js"></script>
</head>
<body class="pear-container pear-admin">
    @RenderBody()
    <script src="~/pear/component/pear/pear.js"></script>
    <script>
        layui.use(['jquery'], function () {
            let $ = layui.jquery;

            // 读取 localStorage 主题颜色值，初始化 iframe 主题
            darkTheme();
            themeColor();

            // iframe 页监听 localStorage [pear 框架主题颜色] 变化。发生变化，同步更新 iframe 显示效果
            window.addEventListener('storage', function(event) {
                if (event.key === 'dark') {
                    darkTheme();
                }
                if(event.key === 'theme-color'){
                    themeColor();
                }
            });

            // 夜间模式切换
            function darkTheme() {
                var $pearAdmin = $(".pear-admin");  // 主体
                var $layuiCard = $('.layui-card');  // 编辑页

                if (localStorage.getItem('dark') === 'true') {
                    $pearAdmin.addClass("pear-admin-dark");
                    $layuiCard.addClass('layui-card-dark');
                } else {
                    $pearAdmin.removeClass("pear-admin-dark");
                    $layuiCard.removeClass('layui-card-dark');
                }
            }

            // 主题颜色切换
            function themeColor(){
                const variableKey = "--global-primary-color";
                const variableVal = localStorage.getItem("theme-color-color");
                document.documentElement.style.setProperty(variableKey, variableVal);
            }
        });
    </script>
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>